import { post, postForm, get, postUpload, postUploadMult, postGetBlob } from '../request'

const prefix = '/dzdt-server'

//  获取菜单详情
export function detailMenu(query) {
  return get(prefix + '/sys/menu/getById', query)
}

// 获取用户详情
export function detailUserApi(query) {
  return get(prefix + '/sys/user/getById', query)
}

// 编辑用户
export function updateUserApi(data) {
  return post(prefix + '/sys/user/update', data)
}

// 上传多个文件
export function uploadMultFile(data) {
  return postUploadMult(prefix + '/sys/upload/uploadFileMult', data)
}
// 上传多个文件
export function uploadFile(data) {
  return postUpload(prefix + '/sys/upload/uploadFile', data)
}

// 获取二维码流文件
export function getQRCode(data) {
  return postGetBlob(prefix + '/sys/upload/getQRCode', data)
}

/**
 * 调用图斑分割接口
 * @param {*} polygon 需进行分割的图斑
 * @param {*} splitLine 分割线
 * @returns 返回分割后的WKT合集
 */
export function splitGeometry(polygon, splitLine) {
  const url = '/landCloudWork/taskGeometrySplit/split';
  try {
    polygon = JSON.stringify(polygon);
    splitLine = JSON.stringify(splitLine);
  } catch (e) {
    console.log(e);
  }
  return postForm(url, { polygon, splitLine });
}
